package com.example.myapplication.ui.mine

import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
import com.example.myapplication.R
import com.example.myapplication.ui.movie.CinemaAdapter
import com.example.myapplication.ui.movie.Cinema_ChooseTimeSlot

data class WantInfo (val want_movie_src:String){
}

class WantInfoAdapter (val wantInfoList:ArrayList<WantInfo>, val context: Context) :
    RecyclerView.Adapter<WantInfoAdapter.ViewHolder>(){

    inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view){
        val want_movie_src:ImageView = view.findViewById<ImageView>(R.id.want_movie_src)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WantInfoAdapter.ViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.wantinfo_item, parent, false)
        val viewHolder = ViewHolder(view)

        view.setOnClickListener {
            Toast.makeText(parent.context, "click date_info", Toast.LENGTH_LONG).show()
            val position = viewHolder.adapterPosition
            val info = wantInfoList[position]

        }
        return viewHolder
    }

    override fun onBindViewHolder(holder: WantInfoAdapter.ViewHolder, position: Int) {
        val movie_src = wantInfoList[position].want_movie_src

        holder.want_movie_src.setImageResource(movie_src.toInt())
    }

    override fun getItemCount(): Int {
        return wantInfoList.size
    }
}